echo "Enlighten directory $enl_bin not found...Exiting"
exit 1
fi
if [ ! -x ${enl_bin}/EventsCli ] ; then
echo "Unable to execute $enl_bin/EventsCli...Exiting"
exit 1
fi
# Create temporary files
temp1="getevents.sql"
temp2="names.tmp"
temp3="clear-env.tmp"
touch $temp1
if [ ! -f $temp1 ] ; then
echo "Unable to create temporary file $temp1 in current directory"
echo "Exiting..."
exit 1
fi
touch $temp2
if [ ! -f $temp2 ] ; then
echo "Unable to create temporary file $temp2 in current directory"
echo "Exiting..."
rm $temp1
exit 1
fi
touch $temp3
if [ ! -f $temp3 ] ; then
echo "Unable to create temporary file $temp3 in current directory"
echo "Exiting..."
rm $temp1
rm $temp2
exit 1
fi
chmod a+rw $temp1
chmod a+rw $temp2
chmod a+rwx $temp3
# Remeber hostname for later use by awk script
echo "host_name $host" > $temp2
# Create sql select statements
echo "select a.test_index, MAX(a.timestamp) mytime, b.class from events_tbl a, event_index_tbl b where a.host_index = (select host_index from host_index_tbl where host_name = \"$host\" ) and a.test_index = b.test_index group by a.test_index, b.class into TEMP tbla ;" > $temp1
echo >> $temp1
echo "select a.severity, b.class, c.test_name from events_tbl a, tbla b, event_index_tbl c where a.test_index = b.test_index and c.test_index = b.test_index and a.timestamp = b.mytime into temp tblb;" >> $temp1
echo >> $temp1
echo "select class, test_name from tblb where severity > 1;" >> $temp1